Repository navigation
feat(agents): 插件可报告 Agent CLI 的最新版本,Core 比较版本、缓存回答并列出可一键更新的 Agent,目录带安装器与安装说明页 - #268
Draft
xiaoyumuxi wants to merge 1 commit into
Draft
xiaoyumuxi wants to merge 1 commit into
xiaoyumuxi wants to merge 1 commit into
Conversation
xiaoyumuxi
force-pushed
the
feat/agent-cli-versions
branch
from
December 3, 2026 17:16
434be1f to
bbc5bfa
Compare
8 of 26 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
关联
改动
都是 API-45、
agents能力 0 内的补充,不升版本。新增一个插件函数latestVersion(普通插件函数,四个 SDK 都能注册,不改 SDK 代码,只更新 README);没有新增宿主方法或通知。一、清单
agents[]新增可选latestVersion: {function}:查 CLI 最新版本的后端函数。它是后端函数,所以需要backend和onAgent:<id>(只有终端形式的 Agent 声明它也要有后端);安装审查新增kind: "agentLatestVersion"程序(agentID、tool、function),因为这个函数会联网,用户安装前要看得到。agents[]新增可选install: {url}:安装说明页。https、有主机名,不带用户名密码、片段、空白和控制字符,最长 2048 字节,可带查询。commandInstallers:它已经声明、校验、进安装审查,并且plugins.commandInstallers.requirements已经按 Agent 列出安装器。二、目录(安装区)
agents.catalog每个条目新增checksLatestVersion(是否声明了latestVersion)。install,或插件有命令安装器提供该 Agent 的工具时,再带install: {installers, url?}:installers是这些安装器的 ID(声明顺序),url是安装说明页。新增DeclarativePluginManifest::agent_installers计算它,规则与requirements里的 Agent 条目一致。plugins.commandInstallers.plan展开用户选的安装器,给用户看过、确认后运行,再重新解析工具。Core 不运行安装命令。三、最新版本:
agents.cliVersions请求:
{ "agents": [ { "agent": "io.github.example.agents/example", "installedVersion": "1.4.0", "toolPath": "/opt/homebrew/bin/example" } ], "check": "ifStale" }installedVersion、toolPath来自宿主的工具解析(已有的版本探测),没找到 CLI 就不带。最多 64 个 Agent,不能重复。check:cached(默认):只读 Core 保存的回答,不问插件;ifStale:只问回答缺失或已满 6 小时的 Agent,上次失败不到 15 分钟的除外。宿主在用户打开 Agent 页时发一次(宿主可让用户关掉);now:每个都问,只接受用户发起的请求。回答:
{ "agents": [{ "agent": "io.github.example.agents/example", "pluginID": "io.github.example.agents", "agentID": "example", "displayName": "Example Agent", "checksLatestVersion": true, "mayRun": true, "installedVersion": "1.4.0", "latest": { "version": "1.5.0", "checkedAtMs": 1764806400000, "stale": false, "publishedAtMs": 1764633600000, "releaseNotesUrl": "https://example.com/agent/releases/1.5.0" }, "comparison": "older", "updateAvailable": true, "update": { "arguments": ["update"] } }], "updates": [ { "agent": "io.github.example.agents/example", "displayName": "Example Agent", "from": "1.4.0", "to": "1.5.0", "arguments": ["update"] } ] }checkFailed: {code, atMs}报告上次失败的检查,latest保留之前成功的回答。updates就是“全部更新”要的清单:比最新版本旧(older)、声明了update、插件有agents.run的 Agent 及其更新命令。宿主给用户看整张清单、确认后在终端逐个运行(和现在单个 Agent 的“更新”一样:toolPath加参数),然后重新探测版本、用cached再读。Core 不运行。四、插件函数
latestVersion{agentID, installedVersion?, toolPath?, timeoutMilliseconds: 20000, maximumResponseBytes: 1048576},最多等 30 秒。{format: "litheAgentLatestVersion", version: 0, latest, publishedAtMs?, releaseNotesUrl?}:latest1–64 字节,只含 ASCII 字母、数字和.、-、_、+;publishedAtMs1..=2^53−1;releaseNotesUrl规则同install.url;format或version都不收。toolPath、installedVersion判断 CLI 是怎么装的、该去哪里查,用 CLI 自己会用的代理和证书,在时限和字节上限内查询;只读,不运行更新,不为别的事联网。五、版本比较
v/V,1–4 段十进制数字(每段最多 19 位,缺的段算 0,所以1.5等于1.5.0),可带-预发布(点分的字母数字和-),可带+构建(忽略)。按 Semantic Versioning 2.0.0 第 11 节比较,得older、same、newer。v后)是否相同:same或different。different不算有更新,Core 不猜顺序。contract/v1/fixtures/agents/cli-versions.json(22 个比较,13 个回答),Core 测试直接读它。六、缓存与联网的取舍
toolPath”有效:插件更新或 CLI 换了安装位置就重新问。agents.configure时丢掉已不存在、或不再声明latestVersion的 Agent 的回答。ifStale因此最多每 6 小时联网一次;用户点“检查”(now)总是重新问。七、错误码与日志
整个请求被拒(
CoreError.details):agents.invalidPayload(已有)invalid_requestcheckagents.userActionRequired(已有)permission_deniedcheck: "now"agents.invalidVersionQuery(新)invalid_requestagents为空或超过 64、同一 Agent 出现两次、installedVersion或toolPath不合规则agents.unknownAgent(已有)entry_not_found单个 Agent 的检查失败不算拒绝,写在该 Agent 的
checkFailed.code:agents.runNotGranted(已有)agents.run,ifStale、now不问它;只报告,不保存agents.backendUnavailable(已有)agents.latestVersionFailed(新)agents.invalidLatestVersion(新)新代码各只有一个含义,已有代码沿用原含义。
新日志事件(
rust/logging/events/agent.json,已重新生成目录):agent.versions.check_finished(info):plugin、agent、check、comparison?、duration_ms;agent.versions.check_failed(warn):同上加reason、call_code?(插件调用自己的失败码);agent.versions.read_finished(debug):check、agents、checked、failed、updates、duration_ms;agent.versions.read_failed(warn):reason。都不记版本号、路径和网址,有测试检查。
八、文档
cli-versions.json。latestVersion、install和“声明了latestVersion需要后端”的条件规则。agents.plugin.json加上两个字段;新增cli-versions.json;invalid-manifests.json加 7 个拒绝用例(函数 ID、未知字段、终端 Agent 没有后端、http、带凭据、带片段、未知install字段)。rust/contracts/rust-core-api.md:新增agents.cliVersions行,agents.catalog行补安装区。domains/agents.md(中英):表格行和新一节“CLI 版本、全部更新与安装”,契约章节和用例表各加一行。agents0 行(中英)。latestVersion怎样注册、收什么、答什么。对宿主的影响
PINNED_CORE_REVISION升到本 PR 的合入提交。要做的有:checkFailed.code显示原因,有发布说明就给链接;ifStale(可在设置里关掉),“检查更新”按钮发now;plugins.commandInstallers.plan,安装说明页用默认浏览器打开;shared/i18n。latestVersion和install,实现查询函数。两个插件已有提供 CLI 的commandInstallers,安装区的安装器不用再加。验证
本机 macOS arm64,基于 main 5364983(含 #263):
cargo test --locked -p lithe-plugin-agents -p lithe-plugin-manifest -p lithe-agent-runtime -p lithe-core -p lithe-diagnosticscargo clippy --locked --all-targets -- -D warnings,cargo check --locked --workspace --all-targets,cargo fmt --all -- --checkLIBSQLITE3_SYS_USE_PKG_CONFIG=1 ZSTD_SYS_USE_PKG_CONFIG=1 PKG_CONFIG_ALLOW_CROSS=1 cargo clippy --locked --target x86_64-pc-windows-msvc -p <crate> --all-targets -- -D warningsverify-docs.mjsgenerate-log-events.mjs --checkverify-rust-core-comments.shverify-platform-tests.mjssdk-e2e.mjs新测试覆盖:
cached从不问插件,ifStale每 6 小时最多问一次,now每次都问;now只接受用户请求,ifStale可以来自宿主的任何请求;toolPath或插件版本重新问,Agent 去掉后丢弃;updates只列older且有update且有agents.run的 Agent;same、newer、different、没有装的版本都不列;latestVersion的 Agent 从不被问;checksLatestVersion和install,安装器按 Agent 的工具挑选;